﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PPAP.BO;
using PPAP.Model;
using System.Data;

namespace PPAP.Web.Frames
{
    public partial class News : PageBase
    {
        PPAPNewsBO pbo = new PPAPNewsBO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Label6.Text = "<a href='#' style=' font-size:11pt; font-family:Arial;' onclick='javascript:more();' >More>></a>";
                PPAPNews p = pbo.GetModel(1);
                if (p != null)
                {
                    lblWelcome.Text = p.CONTENT;
                }
                DataSet ds = new DataSet();
                if (CurrentUser.UnitId == "0" || CurrentUser.UnitId == "99") //供应商
                {
                    ds = pbo.GetList("  id<>1 and( type=2 or type=3) ");
                }
                else
                {
                    ds = pbo.GetList("  id<>1 and ( type=2 or type=1) ");
                }


                if (ds.Tables[0].Rows.Count > 0)
                {
                    tr1.Visible = true;
                    Label1.Text = string.Format("<a href='#' onclick='javascript:view({0});' title='Click me'   style=' font-size:10pt; font-family:Arial;margin-top:10px;' >{1}</a>", ds.Tables[0].Rows[0]["id"].ToString(), DateTime.Parse(ds.Tables[0].Rows[0]["CREATETIME"].ToString()).ToString("yyyy-MM-dd") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.Tables[0].Rows[0]["TITLE"].ToString());
                }

                if (ds.Tables[0].Rows.Count > 1)
                {
                    tr2.Visible = true;
                    Label2.Text = string.Format("<a href='#' onclick='javascript:view({0});' title='Click me'   style=' font-size:10pt; font-family:Arial;margin-top:10px;' >{1}</a>", ds.Tables[0].Rows[1]["id"].ToString(), DateTime.Parse(ds.Tables[0].Rows[1]["CREATETIME"].ToString()).ToString("yyyy-MM-dd") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.Tables[0].Rows[1]["TITLE"].ToString());
                }

                if (ds.Tables[0].Rows.Count > 2)
                {
                    tr3.Visible = true;
                    Label3.Text = string.Format("<a href='#' onclick='javascript:view({0});' title='Click me'    style=' font-size:10pt; font-family:Arial; margin-top:10px;'>{1}</a>", ds.Tables[0].Rows[2]["id"].ToString(), DateTime.Parse(ds.Tables[0].Rows[2]["CREATETIME"].ToString()).ToString("yyyy-MM-dd") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.Tables[0].Rows[2]["TITLE"].ToString());
                }

                if (ds.Tables[0].Rows.Count > 3)
                {
                    tr4.Visible = true;
                    Label4.Text = string.Format("<a href='#' onclick='javascript:view({0});' title='Click me'   style=' font-size:10pt; font-family:Arial;margin-top:10px;' >{1}</a>", ds.Tables[0].Rows[3]["id"].ToString(), DateTime.Parse(ds.Tables[0].Rows[3]["CREATETIME"].ToString()).ToString("yyyy-MM-dd") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.Tables[0].Rows[3]["TITLE"].ToString());
                }

                if (ds.Tables[0].Rows.Count > 4)
                {
                    tr5.Visible = true;
                    Label5.Text = string.Format("<a href='#' onclick='javascript:view({0});' title='Click me'   style=' font-size:10pt; font-family:Arial;margin-top:10px;' >{1}</a>", ds.Tables[0].Rows[4]["id"].ToString(), DateTime.Parse(ds.Tables[0].Rows[4]["CREATETIME"].ToString()).ToString("yyyy-MM-dd") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + ds.Tables[0].Rows[4]["TITLE"].ToString());
                }

                
            }
        }
    }
}